﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Windy.Transformations;
using Windy.TurtleDrawing;
using System.ComponentModel.Composition;

namespace Windy.DragonCurve.Models.Schemes
{
    /// <summary>
    /// Heighway Dragon
    /// 
    /// angle 90°
    /// initial string FX
    /// string rewriting rules
    /// X : X+YF+
    /// Y : -FX-Y
    /// </summary>
    [Export(typeof(DragonCurveScheme))]
    public class HeighwayDragonScheme : DragonCurveScheme
    {
        public HeighwayDragonScheme()
        {
            this.SetupName("Heighway Dragon")
                .SetupInitialSymbols(Symbols.F, Symbols.X)
                .SetupCurveRules
                (
                    new ReplaceTransformRule<Symbols, LinkedListNode<Symbols>, Symbols>(Symbols.F, Symbols.F),
                    new ReplaceTransformRule<Symbols, LinkedListNode<Symbols>, Symbols>(Symbols.Plus, Symbols.Plus),
                    new ReplaceTransformRule<Symbols, LinkedListNode<Symbols>, Symbols>(Symbols.Minus, Symbols.Minus),
                    // X ↦ X+YF+
                    new ExpandTransformRule<Symbols, LinkedListNode<Symbols>, Symbols>(Symbols.X,
                            Symbols.X, Symbols.Plus, Symbols.Y, Symbols.F, Symbols.Plus
                        ),
                    // Y ↦ −FX−Y.\
                    new ExpandTransformRule<Symbols, LinkedListNode<Symbols>, Symbols>(Symbols.Y,
                            Symbols.Minus, Symbols.F, Symbols.X, Symbols.Minus, Symbols.Y
                        )
                )
                .SetupPlotRules(DragonCurvePlotRules.IngnoreVariablePlotingRules)
                .SetupStepAngelDegree(90);
        }


    }
}